<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2007/07/27 07:39:17 $)
// $RCSfile: staff_ajax.php,v $ : $Revision: 1.37 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

if ($_SWIFT["staff"]["t_entab"] == "0")
{
	echo '<font face="Verdana, Arial, Helvetica" size="2" color="red"><b>'.$_SWIFT["language"]["nopermission"].'</b></font>';
	exit;
}

require_once ("./modules/tickets/functions_ticketsui.php");
require_once ("./modules/tickets/functions_ticketmain.php");
require_once ("./modules/tickets/functions_ticketcore.php");
require_once ("./includes/functions_html.php");
require_once ("./includes/data_mimelist.php");

$template->loadLanguageSection("staff_tickets");
$template->loadLanguageSection("predefined");

headerNoCache();
header("Content-type: text/html; charset=".$_SWIFT["language"]["charset"]);

/**
* ###############################################
* FETCH PREDEFINED REPLY
* ###############################################
*/
if (!empty($_GET["predefinedreplyid"]))
{
	require_once ("./modules/tickets/functions_predefined.php");
	
	$_predefinedreply = $dbCore->queryFetch("SELECT * FROM `". TABLE_PREFIX ."predefinedreplies` AS predefinedreplies LEFT JOIN `". TABLE_PREFIX ."predefinedreplydata` AS predefinedreplydata ON (predefinedreplies.predefinedreplyid = predefinedreplydata.predefinedreplyid) WHERE predefinedreplies.predefinedreplyid = '". intval($_GET["predefinedreplyid"]) ."'");
	
	echo $_predefinedreply["contents"];





/**
* ###############################################
* FETCH TICKET POST
* ###############################################
*/
} else if (!empty($_GET["ticketpostid"])) {
	$_ticketpost = $dbCore->queryFetch("SELECT * FROM `". TABLE_PREFIX ."ticketposts` WHERE `ticketpostid` = '". intval($_GET["ticketpostid"]) ."';");
	if (!empty($_ticketpost["ticketpostid"]))
	{
		$_ticketobj =& new TicketMain($_ticketpost["ticketid"], true);
		if ($_ticketobj->ticket)
		{
			$_contents = explode(SWIFT_CRLF, preg_replace("#(\r\n|\r|\n)#s", SWIFT_CRLF, $_ticketpost["contents"]));
			foreach ($_contents as $key=>$val)
			{
				echo "> ".trim($val).SWIFT_CRLF;
			}
		}
	}




/**
* ###############################################
* FETCH SELECT BOX FOR DEPARTMENT STATUS
* ###############################################
*/
} else if ($_GET["action"] == "departmentstatus" && !empty($_GET["departmentid"]) && !empty($_GET["ticketid"])) {
	$_ticketobj =& new TicketMain($_GET["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;

	extract(generateStatusSelectBox($_GET["departmentid"], $_GET["ticketstatusid"]));
	echo 'statusFieldName = "'. cleanVar($_GET['fieldname']) .'"; statusFormName = "'. cleanVar($_GET['formname']) .'";';
	echo $_statusajax;


/**
* ###############################################
* TICKET POST LOCKS
* ###############################################
*/
} else if ($_GET["action"] == "ticketlocks") {
	// ticketid, postcontents
	$_ticketobj =& new TicketMain($_GET["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;

	// See if we already have a ticket lock from THIS staff
	$_ticketpostlock = $dbCore->queryFetch("SELECT * FROM `". TABLE_PREFIX ."ticketpostlocks` WHERE `ticketid` = '". intval($_ticket["ticketid"]) ."' AND `staffid` = '". intval($_SWIFT["staff"]["staffid"]) ."' ORDER BY `dateline` DESC LIMIT 1;");
	$_doupdate = true;
	if (empty($_ticketpostlock["ticketpostlockid"])) // There was no ticket lock
	{
		$dbCore->query("INSERT INTO `". TABLE_PREFIX ."ticketpostlocks` (`ticketid`, `staffid`, `dateline`, `contents`) VALUES ('". intval($_ticket["ticketid"]) ."', '". intval($_SWIFT["staff"]["staffid"]) ."', '". DATENOW ."', '". $dbCore->escape($_GET["postcontents"]) ."');");
		$_ticketpostlock = array('ticketid' => $_ticket["ticketid"], 'staffid' => $_SWIFT["staff"]["staffid"], 'dateline' => DATENOW, 'contents' => $_GET["postcontents"]);
		$_doupdate = false;
	}

	// By now we should have a post lock in place, now see if we have a ticket lock thats not by this staff
	$_ticketpostlockother = $dbCore->queryFetch("SELECT * FROM `". TABLE_PREFIX ."ticketpostlocks` WHERE `ticketid` = '". intval($_ticket["ticketid"]) ."' AND `staffid` != '". intval($_SWIFT["staff"]["staffid"]) ."' ORDER BY `dateline` DESC LIMIT 1;");
	//$_threshold = DATENOW - $_SWIFT["settings"]["t_plockthreshold"];

	if ($_doupdate && !empty($_ticketpostlock["ticketpostlockid"])) // Update the timeline for current lock we have in place
	{
		$dbCore->query("UPDATE `". TABLE_PREFIX ."ticketpostlocks` SET `dateline` = '". DATENOW ."', `contents` = '". $dbCore->escape($_GET["postcontents"]) ."' WHERE `ticketpostlockid` = '". intval($_ticketpostlock["ticketpostlockid"]) ."';");
	}

	$_threshold = DATENOW-$_ticketpostlockother["dateline"];
	// If the timing is greater than the threshold set then move!
	if (!empty($_ticketpostlockother["ticketpostlockid"]) && $_threshold <= $_SWIFT["settings"]["t_plockthreshold"])
	{
		// We found one, now display the data that needs to be printed for this staff
		echo '<table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td class="smalltext"><img src="'. $_SWIFT["themepath"] .'icon_exclamation.gif" border="0" align="absmiddle" /> <span class="postlocktitle">'. sprintf($_SWIFT["language"]["postlockdesc"], htmlspecialchars($_SWIFT["staffcache"][$_ticketpostlockother["staffid"]]["fullname"]), strColorDate(DATENOW-$_ticketpostlockother["dateline"], false)) .'</span>'. iif(!empty($_ticketpostlockother["contents"]), '<BR /><HR class="ticketpostlockhr">'.nl2br(htmlspecialchars($_ticketpostlockother["contents"]))) .'</td></tr></table>';
		exit;
	}

	echo '0';
	exit;

/**
* ###############################################
* HISTORY
* ###############################################
*/
} else if ($_GET["action"] == "history") {
	unset($_userid);

	if (empty($_GET["userid"]) && !empty($_GET["ticketid"]))
	{
		$_ticketobj =& new TicketMain($_GET["ticketid"], true);

		if (!$_ticketobj->ticket)
		{
			echo $_SWIFT["language"]["invalidticket"];
			exit;
		}
		$_ticket = &$_ticketobj->ticket;
		$_userid = $_ticket["userid"];
	} else if (!empty($_GET["userid"])) {
		$_userid = $_GET["userid"];
	}

	$_history = array();

	if (!empty($_GET["email"]))
	{
		if (!is_array($_GET["email"]))
		{
			$_emaillist = array($_GET["email"]);
		} else {
			foreach ($_GET["email"] as $key=>$val)
			{
				if (!empty($val))
				{
					$_emaillist[] = $val;
				}
			}
		}

		$_history = getUserHistoryEmail($_emaillist);
	} else if (!empty($_userid)) {
		// Load the history for this user.
		$_history = getUserHistory($_userid);
	}

	echo '<table border="0" cellpadding="3" cellspacing="1" width="100%" class="tborder"><tr class="tabletitlerow"><td align="left" width="120">'. $_SWIFT["language"]["f_ticketid"] .'</td><td align="left" width="">'. $_SWIFT["language"]["f_subject"] .'</td><td align="center" width="150">'. $_SWIFT["language"]["date"] .'</td><td align="center" width="150">'. $_SWIFT["language"]["f_department"] .'</td><td align="center" width="120">'. $_SWIFT["language"]["f_ticketstatus"] .'</td><td align="center" width="120">'. $_SWIFT["language"]["f_priority"] .'</td></tr>';
	if (_is_array($_history))
	{
		foreach ($_history as $key=>$val)
		{
			if ($val["ticketid"] == $_ticket["ticketid"])
			{
				continue;
			}
			echo '<tr class="'. getRowBG() .'"><td align="left" width="120"><a href="index.php?_m=tickets&_a=viewticket&ticketid='. intval($val["ticketid"]) .'" target="_blank">'. htmlspecialchars(iif($_SWIFT["settings"]["t_eticketid"]=="seq",$val["ticketid"], $val["ticketmaskid"])) .'</a></td><td align="left" width=""><a href="index.php?_m=tickets&_a=viewticket&ticketid='. intval($val["ticketid"]) .'" target="_blank">'. htmlspecialchars($val["subject"]) .'</a></td><td align="center" width="150">'. edate($_SWIFT["settings"]["dt_datetimeformat"], $val["dateline"]) .'</td><td align="center" width="150">'. htmlspecialchars($_SWIFT["departmentcache"][$val["departmentid"]]["title"]) .'</td><td align="center" width="120">'. '<font color=\''. $_SWIFT["statuscache"][$val["ticketstatusid"]]["statuscolor"] .'\'>'.htmlspecialchars($_SWIFT["statuscache"][$val["ticketstatusid"]]["title"]).'</font>' .'</td><td align="center" width="120">'. '<font color=\''. $_SWIFT["prioritycache"][$val["priorityid"]]["frcolorcode"] .'\'>'.htmlspecialchars($_SWIFT["prioritycache"][$val["priorityid"]]["title"]).'</font>' .'</td></tr>';
		}
	}
	echo '</table><BR />';



/**
* ###############################################
* AUDIT LOG
* ###############################################
*/
} else if ($_GET["action"] == "auditlog" && !empty($_GET["ticketid"])) {
	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;
	$_logs = $_ticketobj->getAuditLogs();

	echo '<table border="0" cellpadding="3" cellspacing="1" width="100%" class="tborder"><tr class="tabletitlerow"><td align="left" width="">'. $_SWIFT["language"]["description"] .'</td><td align="center" width="150">'. $_SWIFT["language"]["date"] .'</td><td align="center" width="100">'. $_SWIFT["language"]["timeline"] .'</td><td align="center" width="190">'. $_SWIFT["language"]["entrytype"] .'</td></tr>';

	foreach ($_logs as $key=>$val)
	{
		if ($val["logtype"] == LOG_PARSER)
		{
			$entrytype = $_SWIFT["language"]["alparser"];
		} else if ($val["logtype"] == LOG_STAFF) {
			$entrytype = htmlspecialchars($_SWIFT["staffcache"][$val["staffid"]]["fullname"]). " (".$_SWIFT["language"]["alstaff"].")";
		} else if ($val["logtype"] == LOG_SYSTEM) {
			$entrytype = $_SWIFT["language"]["alsystem"];
		} else if ($val["logtype"] == LOG_ESCALATION) {
			$entrytype = $_SWIFT["language"]["alescalation"];
		} else {
			$entrytype = $_SWIFT["language"]["alclient"];
		}
		
		echo '<tr class="'. getRowBG() .'"><td align="left" width="">'. htmlspecialchars(iif(empty($val["actionmsg"]), $val["actiontype"], $val["actionmsg"])) .'</td><td align="center" width="150">'. edate($_SWIFT["settings"]["dt_datetimeformat"], $val["dateline"]) .'</td><td align="center" width="100">'. strColorDate(DATENOW-$val["dateline"], true) .'</td><td align="center" width="190">'. $entrytype .'</td></tr>'.SWIFT_CRLF;
	}
	echo '</table><BR /> ';





/**
* ###############################################
* FORWARD TAB
* ###############################################
*/
} else if ($_GET["action"] == "forward" && !empty($_GET["ticketid"])) {
	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;
	extract(generateTicketSelectBoxes($_ticket, '', true, 'forwardform'));
	extract(generateStatusSelectBox($_ticket["departmentid"], $_ticket["ticketstatusid"]));

	printFormStart("forwardform", "index.php", "POST", true);
	echo '<table border="0" cellpadding="3" cellspacing="1" width="100%" class="tborder">'.SWIFT_CRLF;

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["from"] .'</span></td>
	<td align="left"><select name="opt_emailqueueid" class="swiftselect">';
	$_queuefrom = false;
	// 1st - Queue Emails
	foreach ($_SWIFT["queuecache"]["list"] as $key=>$val)
	{
		if ($val["departmentid"] == $_ticket["departmentid"])
		{
			$fromname = iif(empty($val["customfromname"]), $_SWIFT["staff"]["fullname"], $val["customfromname"]);
			$fromemail = iif(empty($val["customfromemail"]), $val["email"], $val["customfromemail"]);
			echo '<option value="'. intval($val["emailqueueid"]) .'"'. iif($_ticket["emailqueueid"]==$val["emailqueueid"]," selected") .'>'. htmlspecialchars($fromname) .' &lt;'. htmlspecialchars($fromemail) .'&gt;</option>'.SWIFT_CRLF;
			$_queuefrom = true;
		}
	}

	// Default Return Email
	if (!$_queuefrom)
	{
		echo '<option value="-1" selected>'. htmlspecialchars($_SWIFT["staff"]["fullname"]) .' &lt;'. htmlspecialchars($_SWIFT["settings"]["general_returnemail"]) .'&gt;</option>'.SWIFT_CRLF;
	} else {
		echo '<option value="-1">'. htmlspecialchars($_SWIFT["staff"]["fullname"]) .' &lt;'. htmlspecialchars($_SWIFT["settings"]["general_returnemail"]) .'&gt;</option>'.SWIFT_CRLF;
	}

	// 2nd - Personal Email
	echo '<option value="0">'. htmlspecialchars($_SWIFT["staff"]["fullname"]) .' &lt;'. htmlspecialchars($_SWIFT["staff"]["email"]) .'&gt;</option>'.SWIFT_CRLF;
	echo '</select></td></tr>';

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["to"] .'</span></td>
	<td align="left"><input type="text" size="40" name="opt_to" value="" class="swifttext">&nbsp;&nbsp;( <span class="smalltext"><label for="faddrecipients"><input type="checkbox" id="faddrecipients" name="faddrecipients" value="1" /> '. $_SWIFT["language"]["addtorecp"] .'</label> )&nbsp;&nbsp;<a href="javascript:popupInfoWindow(\''. $_SWIFT["swiftpath"] .'staff/index.php?_m=core&_a=userlookup&formname=forwardform&formfield=opt_to&sessionid='. $_SWIFT["session"]["sessionid"] .'\');"><img src="'. $_SWIFT["themepath"] .'icon_searchlookup.gif" title="'. $_SWIFT["language"]["lookup"] .'" border="0" align="absmiddle" /></a></td></tr>';

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left" id="fmenuref"><span class="tabletitle">'. $_SWIFT["language"]["quickinsert"] .'</span></td>
	<td align="left"><a href="#" title="'. $_SWIFT["qquote"] .'" id="fwquotelink" onClick="javascript:CustomPopupRef(\'fwquotemenu\', event, \'fwquotelink\', \'fwquotemenu\', \'fmenuref\', true);this.blur();" onMouseUp="javascript:this.blur();"><img src="'. $_SWIFT["themepath"] .'icon_quotedrop.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["qquote"] .'&nbsp;<img src="'. $_SWIFT["themepath"] .'menudrop.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" title="'. $_SWIFT["qpredefinedreplies"] .'" id="fprcachelink" onClick="javascript:CustomPopupRef(\'prcachemenu\', event, \'fprcachelink\', \'prcachemenu\', \'fmenuref\', prmenuloaded);this.blur();" onMouseUp="javascript:this.blur();"><img src="'. $_SWIFT["themepath"] .'icon_quickinsert.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["qpredefinedreplies"] .'&nbsp;<img src="'. $_SWIFT["themepath"] .'menudrop.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" title="'. $_SWIFT["qknowledgebase"] .'" id="fkbcachelink" onClick="javascript:CustomPopupRef(\'kbcachemenu\', event, \'fkbcachelink\', \'kbcachemenu\', \'fmenuref\', kbmenuloaded);this.blur();" onMouseUp="javascript:this.blur();"><img src="'. $_SWIFT["themepath"] .'icon_quickinsert.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["qknowledgebase"] .'&nbsp;<img src="'. $_SWIFT["themepath"] .'menudrop.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" title="'. $_SWIFT["qdownloads"] .'" id="fdlcachelink" onClick="javascript:CustomPopupRef(\'dlcachemenu\', event, \'fdlcachelink\', \'dlcachemenu\', \'fmenuref\', dlmenuloaded);this.blur();" onMouseUp="javascript:this.blur();"><img src="'. $_SWIFT["themepath"] .'icon_quickinsert.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["qdownloads"] .'&nbsp;<img src="'. $_SWIFT["themepath"] .'menudrop.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;</td>
	</tr>';
	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["properties"] .'</span></td>
	<td align="left">'. $_SWIFT["language"]["qowner"] .$_poststaffselect.'&nbsp;&nbsp;'. $_SWIFT["language"]["qdepartment"] .$_departmentselect.'&nbsp;&nbsp;'. $_SWIFT["language"]["qstatus"] .'<div id="updatestatusforwardform" style="display:inline;">'.$_poststatusselect.'</div>&nbsp;&nbsp;'. $_SWIFT["language"]["qpriority"] .$_priorityselect.'&nbsp;&nbsp;</td>
	</tr>';

	printDescRow($_SWIFT["language"]["contents"]);
	$colarray = array();
	$colarray[0]["align"] = "left";
	$colarray[0]["valign"] = "top";
	$colarray[0]["colspan"] = "2";
	$colarray[0]["nowrap"] = true;
	$colarray[0]["value"] = '<textarea style="WIDTH:100%;" name="replycontents" cols="100" rows="15" tabindex="99" onselect="javascript:storeCaret(this);" onclick="javascript:storeCaret(this);" onkeyup="javascript:storeCaret(this);">'. htmlspecialchars(iif(!empty($_ticket["draft"]), $_ticket["draft"], $_POST["replycontents"])) .'</textarea>'.SWIFT_CRLF;
	$colarray[0]["class"] = getRowBG();
	printDataRow($colarray);

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["options"] .'</span></td>
	<td align="left"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="180" nowrap><span class="smalltext">'. $_SWIFT["language"]["pdue"] .'<input type="text" name="opt_due" id="opt_fdue" onclick="return showCalendar(\'opt_fdue\', \''. iif($_SWIFT["settings"]["dt_caltype"]=="us", "%m/%d/%Y", "%d/%m/%Y") .'\');" size="12" readonly="1" value="" class="swifttext"/>&nbsp;<img src="'. $_SWIFT["themepath"] .'calendar.gif" id="opt_fduet" onclick="return showCalendar(\'opt_fdue\', \''. iif($_SWIFT["settings"]["dt_caltype"]=="us", "%m/%d/%Y", "%d/%m/%Y") .'\');" style="cursor: pointer;" align="absmiddle"/></span></td><td nowrap><span class="smalltext">'. $_SWIFT["language"]["ptimeworked"] .'<input type="text" name="opt_timeworked" size="12" value="'. $_SWIFT["language"]["inminutes"] .'" onclick="javascript:if(this.value==\''. $_SWIFT["language"]["inminutes"] .'\') { this.value=\'\'; }" class="swifttext"/>&nbsp;</span></td></tr></table>
</td>
	</tr>';

	if ($_ticketobj->ticket["hasattachments"] == 1)
	{
		$_attachments = array();
		unset($_attachmentstore);
		$_index = 0;
		$dbCore->query("SELECT * FROM `". TABLE_PREFIX ."attachments` WHERE `ticketid` = '". intval($_ticketobj->ticket["ticketid"]) ."' ORDER BY `dateline` ASC;");
		while ($dbCore->nextRecord())
		{
			$_attachments[$dbCore->Record["attachmentid"]] = $dbCore->Record;

			$extension = getFileExtension($dbCore->Record["filename"]);
			$mimedata = $mimelist[$extension];
			if (!empty($mimedata[1]))
			{
				$icon = $mimedata[1];
			} else {
				$icon = "mimeico_blank.gif";
			}
			$_attachmentstore .= '<span class="smalltext"><input type="checkbox" name="attachments['. $_index .']" id="attachments['. $_index .']" value="'. intval($dbCore->Record["attachmentid"]) .'" /> <label for="attachments['. $_index .']"><img src="'. $_SWIFT["themepath"] . $icon .'" border="0" align="absmiddle" />&nbsp;'. htmlspecialchars($dbCore->Record["filename"]) .'</a> ('. formattedSize($dbCore->Record["filesize"]) .')</label></span><BR />'.SWIFT_CRLF;
			$_index++;
		}

		echo '<tr class="'. getRowBG() .'">
		<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["forwardattach"] .'</span></td>
		<td align="left">'. $_attachmentstore .'
	</td>
		</tr>';
	}

	// ======= ADD NOTE =======
	echo '<tr class="descrow" title="" onmouseover="" onmouseout="" onclick="" id="fnote1" style="DISPLAY: none;">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["noteoptions"] .'</td>
</tr>
<tr class="row1" title="" onmouseover="" onmouseout="" onclick="" id="fnote2" style="DISPLAY: none;">
<td class="row1" align="left" valign="top" colspan=""><span class="tabletitle">'.$_SWIFT["language"]["notetype"].'</span></td>
<td class="row1" align="left" valign="top" colspan=""><label for="fnotetype[0]"><input type="radio" id="fnotetype[0]" name="notetype" value="'. NOTE_TICKET .'" checked /> <span class="smalltext">'. $_SWIFT["language"]["ticket"] .'</label></span>

<label for="fnotetype[1]"><input type="radio" id="fnotetype[1]" name="notetype" value="'. NOTE_USER .'" /> <span class="smalltext">'. $_SWIFT["language"]["user"] .'</label></span>
</td>
</tr>
<tr class="row2" title="" onmouseover="" onmouseout="" onclick="" id="fnote3" style="DISPLAY: none;">
<td class="row1" align="left" valign="top" colspan="2" width=""><textarea style="WIDTH:100%;" name="notecontents" cols="100" rows="3">'. htmlspecialchars($_POST["notecontents"]) .'</textarea>
</td>
</tr>';

	// ======= ATTACH FILES =======
	$attachrowjs = "switchDisplay('fattach0');";
	echo '<tr class="descrow" title="" onmouseover="" onmouseout="" onclick="" id="fattach0" style="DISPLAY: none;">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["attachfile"] .'</td>
</tr>';

$index = 1;
if (empty($_SWIFT["settings"]["t_maxattach"]))
{
	$maxattach = 3;
} else {
	$maxattach = intval($_SWIFT["settings"]["t_maxattach"]);
}

for ($ii=0; $ii<$maxattach; $ii++)
{
	$rowclass = getRowBG();
	$attachrowjs .= "switchDisplay('fattach". $index ."');";
	echo '<tr class="'. $rowclass .'" title="" onmouseover="" onmouseout="" onclick="" id="fattach'. $index .'" style="DISPLAY: none;">
<td class="'. $rowclass .'" align="left" valign="top" colspan=""><span class="tabletitle">'.sprintf($_SWIFT["language"]["attachfilen"], $index).'</span></td>
<td class="'. $rowclass .'" align="left" valign="top" colspan=""><input type="file" name="opt_file['. $index .']" value="" size="35" class="swifttext" />
</td>
</tr>';
	$index++;
}

	// ======= DOWNLOADS LINK =======
	echo '<tr class="descrow" title="" onmouseover="" onmouseout="" onclick="" id="fdownloads1" style="DISPLAY: none;">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["qdownloads"] .'</td>
</tr>

<tr class="row1" title="" onmouseover="" onmouseout="" onclick="" id="fdownloads2" style="DISPLAY: none;">
<td class="row1" align="left" valign="top" colspan="2"><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td width="400" align="left"><select name="opt_downloads[]" class="swiftselect" size="5" style="WIDTH: 100%;" multiple></select></td><td align="left" valign="middle"><input type="button" onClick="javascript:removeDLItem();" class="bluebuttonsuperbig" value="'. $_SWIFT["language"]["removefile"] .'" /><BR /><BR /><BR /><input type="button" class="bluebuttonsuperbig" onClick="javascript:clearDLItems();" value="'. $_SWIFT["language"]["cancel"] .'" /></td></tr></table>
</td>
</tr>
';

	echo '<tr class="descrow" id="fodescfollowup" title="" onmouseover="" onmouseout="" onclick="" style="display:none;">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["tabfollowup"] .'</td>
</tr>
<tr class="row1" id="fofollowupstoredisp" style="display:none;">
<td class="row1" align="left" id="fofollowupstore" valign="top" colspan="2"><span class="smalltext"><img src="'. $_SWIFT["themepath"] .'loadingcircle.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["loading"] .'</span></td>
</tr>';



	$data[0]["value"] = '<input type="submit" class="yellowbuttonbig" onClick="javascript:processReplyForm();" value="'. $_SWIFT["language"]["send"] .'" />&nbsp;&nbsp;<input type="submit" class="bluebuttonsuperbig" value="'. $_SWIFT["language"]["saveasdraft"] .'" onClick="javascript:document.forwardform.saveasdraft.value=\'2\';" />&nbsp;&nbsp;<input type="button" onClick="javascript:renderFollowUpSubSection(\'forward\', \''. $_ticket["ticketid"] .'\');" class="bluebuttonbig" value="'. $_SWIFT["language"]["tabfollowup"] .'" />&nbsp;&nbsp;<input type="button" onClick="javascript:switchDisplay(\'fnote1\');switchDisplay(\'fnote2\');switchDisplay(\'fnote3\');" class="bluebuttonbig" value="'. $_SWIFT["language"]["addnote"] .'" />&nbsp;&nbsp;<input type="button" onClick="javascript:'. $attachrowjs .'" class="bluebuttonbig" value="'. $_SWIFT["language"]["attachfile"] .'" />&nbsp;&nbsp;<input type="button" onClick="javascript:openSpellChecker();" class="bluebuttonbig" value="'. $_SWIFT["language"]["spellcheck"] .'" />&nbsp;&nbsp;'.SWIFT_CRLF;
	$data[0]["align"] = "left";
	$data[0]["colspan"] = 2;
	printDataRow($data);

	echo '</table><BR /> ';
	addHiddenField("_m", "tickets");
	addHiddenField("_a", "ticketactions");
	addHiddenField("action", "forward");
	addHiddenField("saveasdraft", "1");
	addHiddenField("ticketlabelid", $_REQUEST["ticketlabelid"]);
	addHiddenField("ticketid", $_ticket["ticketid"]);
	printFormEnd();







/**
* ###############################################
* RELEASE TAB
* ###############################################
*/
} else if ($_GET["action"] == "release" && !empty($_GET["ticketid"])) {
	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;
	extract(generateTicketSelectBoxes($_ticket, '', true, 'releaseform'));
	extract(generateStatusSelectBox($_ticket["departmentid"], $_ticket["ticketstatusid"]));

	printFormStart("releaseform", "index.php", "POST", true);
	echo '<table border="0" cellpadding="3" cellspacing="1" width="100%" class="tborder">'.SWIFT_CRLF;

	echo '<tr class="'. getRowBG() .'">
	<td align="left" colspan="2">'. $_SWIFT["language"]["qowner"] .$_staffselect.'&nbsp;&nbsp;'. $_SWIFT["language"]["qdepartment"] .$_departmentselect.'&nbsp;&nbsp;'. $_SWIFT["language"]["qstatus"] .'<div id="updatestatusreleaseform" style="display:inline;">'.$_statusselect.'</div>&nbsp;&nbsp;'. $_SWIFT["language"]["qpriority"] .$_priorityselect.'&nbsp;&nbsp;</td>
	</tr>';

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["options"] .'</span></td>
	<td align="left"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="180" nowrap><span class="smalltext">'. $_SWIFT["language"]["pdue"] .'<input type="text" name="opt_due" id="opt_rdue" onclick="return showCalendar(\'opt_rdue\', \''. iif($_SWIFT["settings"]["dt_caltype"]=="us", "%m/%d/%Y", "%d/%m/%Y") .'\');" size="12" readonly="1" value="" class="swifttext"/>&nbsp;<img src="'. $_SWIFT["themepath"] .'calendar.gif" id="opt_rduet" onclick="return showCalendar(\'opt_rdue\', \''. iif($_SWIFT["settings"]["dt_caltype"]=="us", "%m/%d/%Y", "%d/%m/%Y") .'\');" style="cursor: pointer;" title="'. $title .'" align="absmiddle"/></span></td><td nowrap><span class="smalltext">'. $_SWIFT["language"]["ptimeworked"] .'<input type="text" name="opt_timeworked" size="12" value="'. $_SWIFT["language"]["inminutes"] .'" onclick="javascript:if(this.value==\''. $_SWIFT["language"]["inminutes"] .'\') { this.value=\'\'; }" class="swifttext"/>&nbsp;</span></td></tr></table>
</td>
	</tr>';

	echo '<tr class="descrow" title="" onmouseover="" onmouseout="" onclick="">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["noteoptions"] .'</td>
</tr>
<tr class="row1" title="" onmouseover="" onmouseout="" onclick="">
<td class="row1" align="left" valign="top" colspan=""><span class="tabletitle">'.$_SWIFT["language"]["notetype"].'</span></td>
<td class="row1" align="left" valign="top" colspan=""><label for="fnotetype[0]"><input type="radio" id="fnotetype[0]" name="notetype" value="'. NOTE_TICKET .'" checked /> <span class="smalltext">'. $_SWIFT["language"]["ticket"] .'</label></span>

<label for="fnotetype[1]"><input type="radio" id="fnotetype[1]" name="notetype" value="'. NOTE_USER .'" /> <span class="smalltext">'. $_SWIFT["language"]["user"] .'</label></span>
</td>
</tr>
<tr class="row2" title="" onmouseover="" onmouseout="" onclick="">
<td class="row1" align="left" valign="top" colspan="2" width=""><textarea style="WIDTH:100%;" name="notecontents" cols="100" rows="3">'. htmlspecialchars($_POST["notecontents"]) .'</textarea>
</td>
</tr>';


	echo '<tr class="descrow" id="reldescfollowup" title="" onmouseover="" onmouseout="" onclick="" style="display:none;">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["tabfollowup"] .'</td>
</tr>
<tr class="row1" id="relfollowupstoredisp" style="display:none;">
<td class="row1" align="left" id="relfollowupstore" valign="top" colspan="2"><span class="smalltext"><img src="'. $_SWIFT["themepath"] .'loadingcircle.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["loading"] .'</span></td>
</tr>';

	$data[0]["value"] = '<input type="submit" class="yellowbuttonbig" onClick="javascript:processReplyForm();" value="'. $_SWIFT["language"]["submit"] .'" />&nbsp;&nbsp;<input type="button" onClick="javascript:renderFollowUpSubSection(\'release\', \''. $_ticket["ticketid"] .'\');" class="bluebuttonbig" value="'. $_SWIFT["language"]["tabfollowup"] .'" />'.SWIFT_CRLF;
	$data[0]["align"] = "left";
	$data[0]["colspan"] = 2;
	printDataRow($data);

	echo '</table><BR /> ';
	addHiddenField("_m", "tickets");
	addHiddenField("_a", "ticketactions");
	addHiddenField("action", "release");
	addHiddenField("ticketlabelid", $_REQUEST["ticketlabelid"]);
	addHiddenField("ticketid", $_ticket["ticketid"]);
	printFormEnd();







/**
* ###############################################
* FOLLOW-UP TAB
* ###############################################
*/
} else if ($_GET["action"] == "followup" && !empty($_GET["ticketid"])) {
	require_once ("./modules/tickets/functions_followup.php");

	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;

	renderFollowUpTabContents($_ticketobj, iif($_GET["noform"]==1, true, false), iif($_GET["nomenus"]==1, true, false));


/**
* ###############################################
* ADD NOTES
* ###############################################
*/
} else if ($_GET["action"] == "addnotes" && !empty($_GET["ticketid"])) {
	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;

	printFormStart("noteform");
	echo '<table border="0" cellpadding="3" cellspacing="1" width="100%" class="tborder">'.SWIFT_CRLF;
	printDescRow($_SWIFT["language"]["noteoptions"]);
	$options = array();
	$options[0]["title"] = $_SWIFT["language"]["ticket"];
	$options[0]["value"] = NOTE_TICKET;
	$options[0]["checked"] = true;
	$options[1]["title"] = $_SWIFT["language"]["user"];
	$options[1]["value"] =NOTE_USER;
	printRadioRow("notetype", $_SWIFT["language"]["notetype"], $_SWIFT["language"]["desc_notetype"], $options, "", true);
	$options = array();
	$options[0]["title"] = $_SWIFT["language"]["noteallstaff"];
	$options[0]["value"] = "0";
	$options[0]["selected"] = true;
	$index = 1;
	foreach ($_SWIFT["staffcache"] as $key=>$val)
	{
		$options[$index]["title"] = $val["fullname"];
		$options[$index]["value"] = $val["staffid"];
		$index++;
	}
	printSelectRow("forstaffid", $_SWIFT["language"]["forstaffnote"], $_SWIFT["language"]["desc_forstaffnote"], $options);
	printDescRow($_SWIFT["language"]["contents"]);
	$colarray = array();
	$colarray[0]["align"] = "left";
	$colarray[0]["valign"] = "top";
	$colarray[0]["colspan"] = "2";
	$colarray[0]["nowrap"] = true;
	$colarray[0]["value"] = '<textarea style="WIDTH:100%;" name="notecontents" cols="100" rows="3">'. htmlspecialchars($_POST["notecontents"]) .'</textarea>'.SWIFT_CRLF;
	$colarray[0]["class"] = getRowBG();
	printDataRow($colarray);
	printSubmitRow($_SWIFT["language"]["addnote"]);
	echo '</table><BR />';
	addHiddenField("_m", "tickets");
	addHiddenField("_a", "ticketactions");
	addHiddenField("action", "addnote");
	addHiddenField("ticketlabelid", $_REQUEST["ticketlabelid"]);
	addHiddenField("ticketid", $_ticket["ticketid"]);
	printFormEnd();




/**
* ###############################################
* EDIT TAB
* ###############################################
*/
} else if ($_GET["action"] == "edit" && !empty($_GET["ticketid"])) {
	require_once ("./includes/functions_customfields.php");

	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;

	printFormStart("editform");
	echo '<table border="0" cellpadding="3" cellspacing="1" width="100%" class="tborder">'.SWIFT_CRLF;
	renderStaffCustomFields(CUSTOMFIELD_USERTICKET, false, $_ticket["ticketid"], $_ticket["ticketid"]);
	renderStaffCustomFields(CUSTOMFIELD_STAFFTICKET, false, $_ticket["ticketid"], $_ticket["ticketid"]);
	//Mahesh Slaria: Staff & user ticket creation
	renderStaffCustomFields(CUSTOMFIELD_STAFFUSERTICKET, false, $_ticket["ticketid"], $_ticket["ticketid"]);

	printDescRow($_SWIFT["language"]["linkcfgroup"]);

	$options = array();
	$index = 1;
	$options[0]["title"] = $_SWIFT["language"]["cfnolink"];
	$options[0]["value"] = "0";
	$options[0]["selected"] = true;
	$dbCore->query("SELECT * FROM `". TABLE_PREFIX ."customfieldgroups` WHERE `grouptype` IN ('". CUSTOMFIELD_USERTICKET ."', '". CUSTOMFIELD_STAFFTICKET ."', '". CUSTOMFIELD_STAFFUSERTICKET ."');");
	while ($dbCore->nextRecord())
	{
		$options[$index]["title"] = $dbCore->Record["title"];
		$options[$index]["value"] = $dbCore->Record["customfieldgroupid"];
		$index++;
	}
	printSelectRow("linkcustomfieldgroupid", $_SWIFT["language"]["linkwithcfg"], $_SWIFT["language"]["desc_linkwithcfg"], $options);

	printDescRow($_SWIFT["language"]["ticketrecipients"]);

	$data = array();
	$data[0]["value"] = '<span class="smalltext">'. $_SWIFT["language"]["dticketrecipients"] .'</span>'.SWIFT_CRLF;
	$data[0]["align"] = "left";
	$data[0]["colspan"] = "2";
	printDataRow($data);

	$_recipients = $_ticketobj->getRecipients();
	foreach ($_recipients as $key=>$val)
	{
		if ($val["recipienttype"] == RECIPIENT_THIRDPARTY)
		{
			$img = "img_blockthirdparty.gif";
		} else if ($val["recipienttype"] == RECIPIENT_CCUSER) {
			$img = "img_blockccuser.gif";
		} else if ($val["recipienttype"] == RECIPIENT_BCCUSER) {
			$img = "img_blockbccuser.gif";
		}
		
		$data = array();
		$data[0]["value"] = '<table border="0" cellpadding="2" cellspacing="1" width="100%"><tr class="'. getRowBG() .'"><td width="1" align="left"><img src="'. $_SWIFT["themepath"].$img .'" border="0" /></td><td align="left><span class="smalltext">'. htmlspecialchars($val["email"]) .'</span></td>'. iif($_SWIFT["staff"]["tdelrecipients"] != "0", '<td width="1" align="right"><a href="index.php?_m=tickets&_a=ticketactions&action=delrecipient&ticketid='. intval($_ticket["ticketid"]) .'&recipientid='. intval($val["recipientid"]) .'"><img src="'. $_SWIFT["themepath"].'icon_delete.gif" border="0" /></a></td>') .'</tr></table>'.SWIFT_CRLF;
		$data[0]["align"] = "left";
		$data[0]["colspan"] = "2";
		printDataRow($data);
	}

	echo '<tr class="'. getRowBG() .'" title="" onmouseover="" onmouseout="" onclick="" id="" style="">

<td align="left" valign="top" colspan="" width="50%"><span class="tabletitle">Add New Recipient</span><BR /><span class="tabledescription">You can add a new Recipient by selecting the Recipient Type and specifying the Recipient Email Address. The added recipient will receive the entire staff replies automatically, but will not have access to view the ticket online.</span></td>
<td align="left" valign="top" colspan="" width=""><select name="recipienttype" class="swiftselect"><option value="thirdparty">'. $_SWIFT["language"]["rthirdparty"] .'</option><option value="ccuser">'. $_SWIFT["language"]["rccuser"] .'</option><option value="bccuser">'. $_SWIFT["language"]["rbccuser"] .'</option></select><BR /><input type="text" class="swifttext" name="recipient" id="recipient" value="" size="30" />
</td>
</tr>';


	if ($_SWIFT["staff"]["tmerge"] != "0")
	{
		printDescRow($_SWIFT["language"]["mergeticket"]);
		printTextRow("mergeticketid", $_SWIFT["language"]["mergewith"], $_SWIFT["language"]["desc_mergewith"], "text", $_POST["mergeticketid"]);
	}

	printDescRow($_SWIFT["language"]["ticketproperties"]);
	printTextRow("subject", $_SWIFT["language"]["s_subject"], "", "text", htmlspecialchars($_ticket["subject"]));
	printTextRow("email", $_SWIFT["language"]["f_email"], "", "text", $_ticket["email"]);
	printTextRow("fullname", $_SWIFT["language"]["s_fullname"], "", "text", $_ticket["fullname"]);

	printSubmitRow($_SWIFT["language"]["update"]);
	echo '</table><BR />';
	addHiddenField("_m", "tickets");
	addHiddenField("_a", "ticketactions");
	addHiddenField("action", "edit");
	addHiddenField("ticketid", $_ticket["ticketid"]);
	printFormEnd();






/**
* ###############################################
* BILLING TAB
* ###############################################
*/
} else if ($_GET["action"] == "billing" && !empty($_GET["ticketid"])) {
	require_once ("./includes/functions_customfields.php");

	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;

	printFormStart("billingform");
	echo '<table border="0" cellpadding="3" cellspacing="1" width="100%" class="tborder">'.SWIFT_CRLF;

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left" valign="top"><span class="tabletitle">'. $_SWIFT["language"]["timespent"] .'</span></td>
	<td align="left"><span class="smalltext">'. $_SWIFT["language"]["tworked"] .'<input type="text" name="tworked" size="10" onBlur="if (document.billingform.tbillable.value == \'\') { document.billingform.tbillable.value = this.value; } return true;" class="swifttext"/>&nbsp;&nbsp;&nbsp;&nbsp;'. $_SWIFT["language"]["tbillable"] .'<input type="text" name="tbillable" size="10" class="swifttext"/>&nbsp;&nbsp;'. $_SWIFT["language"]["tdesc"] .'</span></td>
	</tr>';

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left" valign="top"><span class="tabletitle">'. $_SWIFT["language"]["billdate"] .'</span></td>
	<td align="left"><input type="text" name="billdate" id="billdate" onclick="return showCalendar(\'billdate\', \''. iif($_SWIFT["settings"]["dt_caltype"]=="us", "%m/%d/%Y", "%d/%m/%Y") .' %H:%M\', \'12\');" size="22" readonly="1" value="'. edate(iif($_SWIFT["settings"]["dt_caltype"]=="us", "m/d/Y H:i", "d/m/Y H:i")) .'" class="swifttext"/>&nbsp;<img src="'. $_SWIFT["themepath"] .'calendar.gif" id="billdateb" onclick="return showCalendar(\'billdate\', \''. iif($_SWIFT["settings"]["dt_caltype"]=="us", "%m/%d/%Y", "%d/%m/%Y") .' %H:%M\', \'12\');" style="cursor: pointer;" align="absmiddle"/></td>
	</tr>';

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left" valign="top"><span class="tabletitle">'. $_SWIFT["language"]["worker"] .'</span></td>
	<td align="left"><select name="workerstaffid" class="swiftselect">';
	foreach ($_SWIFT["staffcache"] as $key=>$val)
	{
		echo '<option value="'. $val["staffid"] .'"'. iif($val["staffid"]==$_SWIFT["staff"]["staffid"], " selected") .'>'. $val["fullname"] .'</option>'.SWIFT_CRLF;
	}
	echo '</select></td>
	</tr>';

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left" valign="top"><span class="tabletitle">'. $_SWIFT["language"]["summary"] .'</span></td>
	<td align="left"><textarea style="WIDTH:100%;" name="billsummary" cols="100" rows="6" style="width:99%;">'. htmlspecialchars($_POST["billsummary"]) .'</textarea></td>
	</tr>';

	renderStaffCustomFields(CUSTOMFIELD_TIMETRACK);

	printSubmitRow($_SWIFT["language"]["insert"]);
	echo '</table><BR />';
	addHiddenField("_m", "tickets");
	addHiddenField("_a", "ticketactions");
	addHiddenField("action", "billing");
	addHiddenField("ticketid", $_ticket["ticketid"]);
	printFormEnd();




/**
* ###############################################
* FORWARD QUOTE CLIENT POSTS
* ###############################################
*/
} else if ($_GET["action"] == "forwardquote" && !empty($_GET["ticketid"])) {
	require_once ("./includes/functions_customfields.php");

	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;
	$_posts = $_ticketobj->getTicketPosts(false, false, "asc", false, true);

	foreach ($_posts as $key=>$val)
	{
		if ($val["creator"] == POST_CLIENT)
		{
			echo $val["fullname"]." ".sprintf($_SWIFT["language"]["trdate"], edate($_SWIFT["settings"]["dt_datetimeformat"], $val["dateline"]))."\n";
			echo "================================================================\n";
			echo $val["contents"]."\n\n\n";
		}
	}




/**
* ###############################################
* FORWARD QUOTE ALL
* ###############################################
*/
} else if ($_GET["action"] == "forwardquoteall" && !empty($_GET["ticketid"])) {
	require_once ("./includes/functions_customfields.php");

	$_ticketobj =& new TicketMain($_REQUEST["ticketid"], true);

	if (!$_ticketobj->ticket)
	{
		echo $_SWIFT["language"]["invalidticket"];
		exit;
	}
	$_ticket = &$_ticketobj->ticket;
	$_posts = $_ticketobj->getTicketPosts(false, false, "asc", false, true);

	foreach ($_posts as $key=>$val)
	{
		echo $val["fullname"]." ".sprintf($_SWIFT["language"]["trdate"], edate($_SWIFT["settings"]["dt_datetimeformat"], $val["dateline"]))."\n";
		echo "================================================================\n";
		echo $val["contents"]."\n\n\n";
	}




/**
* ###############################################
* TICKET REPORTS
* ###############################################
*/
} else if ($_GET["action"] == "ticketreports" && !empty($_GET["userid"])) {
	require_once ("./modules/tickets/report_ajaxreport.php");
}


?>